package JVM相关知识;

import java.util.ArrayList;
import java.util.List;

/**
 * @author coderFu
 * @create 2022/1/4
 * java 的内存监控、管理工具
 */
public class JconsoleAnalysisTest {

    /**
     * 一次分配内存64KB
     */
    public byte[] bytes = new byte[64*1024];

    public static void main(String[] args) throws InterruptedException {
        new JconsoleAnalysisTest().addHeap(1000);

    }

    public void  addHeap(int num) throws InterruptedException {
        List<byte[]> list = new ArrayList<>();
        for (int i = 0; i < num; i++) {
            Thread.sleep(50L);
            list.add(bytes);
        }
        System.gc();
    }
}
